home *** CD-ROM | disk | FTP | other *** search
Text File | 1993-11-04 | 12.3 KB | 409 lines | [TEXT/MPS ] |
- //234567890123456789012345678901234567890123456789012345678901234567890123456789
- //===========================================================================
- // File: SecurityShell.c
- //
- // This file contains a shell for add-on security modules for Apple
- // Remote Access. This code can be duplicated to write an add-on
- // security code module.
- //
- // Copyright © 1992, 1993 Apple Computer Inc.
- // All rights reserved
- //
- // Author: Farzad Sarabi
- //
- // Modification history:
- //
- // 5/10/1993 Farzad A little cleanup, and added a completion routine.
- // Some more comments
- // 10/6/1992 Farzad Created
- //===========================================================================
-
-
-
- #include "SecurityInterface.h"
-
-
- // #define SecurityShellVersion 0x0090
-
-
- //===========================================================================
- // Example of Your Code
- //===========================================================================
-
- // function prototypes
- static long DoMyStartup( SecurityReference MyReference,
- long LongParam );
- static long DoMyShutdown( SecurityReference MyReference,
- long LongParam );
- static long DoMyBegin( SecurityReference MyReference,
- long LongParam );
- static long DoMyEnd( SecurityReference MyReference,
- long LongParam );
- static long DoMyDataHandler( SecurityReference MyReference,
- long LongParam );
- static long DoMyAbortHandler( SecurityReference MyReference,
- long LongParam );
- static long DoMyTickleHandler( SecurityReference MyReference,
- long LongParam );
- pascal void MyCompletionProc( SecurityReference MyReference,
- int ResultCode,
- void * DataPtr,
- int DataSize,
- long CompletionParam );
-
-
-
-
- // the following is a shell for your code. It shows how your entry routine
- // should be structured. Empty supporting routines for the actions are
- // provided.
-
-
- // WARNING:
- // Don't change the name of this routine. We may change it in the
- // future. This is the routine ARA expects and calls.
-
- pascal long MySecurityProcEntry( SecurityActions Action,
- SecurityReference MyReference,
- long LongParam )
- //===========================================================================
- // Description: this is the entry point for the ??? security operation.
- // It is called by AppleTalk Remote Access to have this
- // security module perform the given operation. It
- // dispatches to a variety of routines based on the
- // requested action.
- //
- // Parameters: Action the action to be performed
- // MyReference this is a unique value representing
- // this instance of this code module.
- // DataPtr the data for this action
- // DataSize the size of data
- //
- // Return Value: long result code, nonzero indicates an
- // error. Its value is one of the
- // SecurityResultCodes.
- //
- // Creation Date:
- //
- // Modifications:
- //
- //===========================================================================
- {
- switch ( Action ) {
-
- case kSecurityStartup:
- return DoMyStartup( MyReference, LongParam );
-
-
- case kSecurityShutdown:
- return DoMyShutdown( MyReference, LongParam );
-
-
- case kSecurityBegin:
- return DoMyBegin( MyReference, LongParam );
-
-
- case kSecurityEnd:
- return DoMyEnd( MyReference, LongParam );
-
-
- case kSecurityDataAvailable:
- return DoMyDataHandler( MyReference, LongParam );
-
-
- case kSecurityAbort:
- return DoMyAbortHandler( MyReference, LongParam );
-
-
- case kSecurityTickleAction:
- return DoMyTickleHandler( MyReference, LongParam );
-
- }
-
- return ( kSecurityUnsupportedAction );
- }
-
-
-
-
- static long DoMyStartup( SecurityReference MyReference,
- long LongParam )
- //===========================================================================
- // Description: this routine handles the kSecurityStartup action. You
- // should allocate any memory and setup the working
- // environment (e.g. A5 world) here.
- //
- // Parameters: MyReference My unique reference
- // LongParam additional information
- //
- // Return Value: long result code, nonzero indicates error
- //
- // Creation Date:
- //
- // Modifications:
- //
- //===========================================================================
- {
- #pragma unused(MyReference)
- #pragma unused(LongParam)
-
- // this routine is called when the module has just been loaded. You
- // can preallocate any memory you need. You are not yet starting any
- // to do what this code resource is responsible for.
-
- // You can allocate and release memory in this routine.
-
- return ( kSecurityNoErr );
- }
-
-
-
- static long DoMyShutdown( SecurityReference MyReference,
- long LongParam )
- //===========================================================================
- // Description: this routine handles the kSecurityShutdown action. You
- // should release any memory allocated by the DoMyStartup
- // routine.
- //
- // Parameters: MyReference My unique reference
- // LongParam additional information
- //
- // Return Value: long result code, nonzero indicates error
- //
- // Creation Date:
- //
- // Modifications:
- //
- //===========================================================================
- {
- #pragma unused(MyReference)
- #pragma unused(LongParam)
-
- // this is the last routine that is called before your code resource
- // is released. Just do any cleanup you need to perform. ARA services
- // are no longer available.
-
- // You can allocate and release memory in this routine.
-
- return ( kSecurityNoErr );
- }
-
-
-
- static long DoMyBegin( SecurityReference MyReference,
- long LongParam )
- //===========================================================================
- // Description: this routine handles the kSecurityBeing action. This
- // routine should start the operations the code resource
- // must do. For example an authentication code resource
- // should start the authentication process.
- //
- // Parameters: MyReference My unique reference
- // LongParam additional information
- //
- // Return Value: long result code, nonzero indicates error
- //
- // Creation Date:
- //
- // Modifications:
- //
- //===========================================================================
- {
- #pragma unused(MyReference)
- #pragma unused(LongParam)
-
- // This routine is called to actually start the code resource to do
- // what it's responsible for. E.g. an authentication code resource
- // should start the authentication process. A configuration module
- // can start displaying a dialog etc.
-
- // You can allocate and release memory in this routine.
-
- return ( kSecurityNoErr );
- }
-
-
-
- static long DoMyEnd( SecurityReference MyReference,
- long LongParam )
- //===========================================================================
- // Description: this routine handles the kSecurityEnd action. The action
- // is sent to signal the end of the operation the code
- // resource was created to do.
- //
- // Parameters: MyReference My unique reference
- // LongParam additional information
- //
- // Return Value: long result code, nonzero indicates error
- //
- // Creation Date:
- //
- // Modifications:
- //
- //===========================================================================
- {
- #pragma unused(MyReference)
- #pragma unused(LongParam)
-
- // This routine is called when the code resource is finished. It is
- // called as a result of you calling ARAAllowUser, ARADontAllowUser,
- // ARACompleteOperation, or after ARA aborts your code resource.
- // You could for example cleanup any outstanding asynch calls to the
- // Mac OS. ARA services are no longer available.
-
- // You can allocate and release memory in this routine.
-
- return ( kSecurityNoErr );
- }
-
-
-
- static long DoMyDataHandler( SecurityReference MyReference,
- long LongParam )
- //===========================================================================
- // Description: this routine handles the kSecurityDataAvailable action.
- // The action is sent when data has arrived for the code
- // resource.
- //
- // Parameters: MyReference My unique reference
- // LongParam additional information
- //
- // Return Value: long result code, nonzero indicates error
- //
- // Creation Date:
- //
- // Modifications:
- //
- //===========================================================================
- {
- #pragma unused(MyReference)
- #pragma unused(LongParam)
-
- // This routine is not used in this release of the ARA Add-on Security.
- // In future releases we may use this to indicate data being available
- // for you. ARA may in the future send events to a modeless dialog
- // box using the DataAvailable message.
-
- // You can allocate and release memory in this routine.
-
- return ( kSecurityNoErr );
- }
-
-
-
- static long DoMyAbortHandler( SecurityReference MyReference,
- long LongParam )
- //===========================================================================
- // Description: this routine handles the kSecurityAbort action. The
- // abort action is sent when the code resources operation
- // needs to be terminated abnormally.
- //
- // Parameters: MyReference My unique reference
- // LongParam additional information
- //
- // Return Value: long result code, nonzero indicates error
- //
- // Creation Date:
- //
- // Modifications:
- //
- //===========================================================================
- {
- // you can remove the unused pragma for any of the parameters you use
- #pragma unused(MyReference)
- #pragma unused(LongParam)
-
- // This routine is called when the code resource is being aborted.
- // You should not make any more calls to ARA services, and you should
- // start your abort process. You will receive the End and Shutdown
- // actions a little while later.
-
- // You can allocate and release memory in this routine.
-
- return ( kSecurityNoErr );
- }
-
-
-
- static long DoMyTickleHandler( SecurityReference MyReference,
- long LongParam )
- //===========================================================================
- // Description: this routine handles the kSecurityTickle action. ARA
- // sends this action periodically. The action is also
- // generated as a result of a call to ARATickleMe routine.
- //
- //
- // Parameters: MyReference My unique reference
- // LongParam When ARA calls this value will be 0,
- // otherwise it is the value passed to
- // the ARATickleMe routine.
- //
- // Return Value: long result code, nonzero indicates error
- //
- // Creation Date:
- //
- // Modifications:
- //
- //===========================================================================
- {
- // you can remove the unused pragma for any of the parameters you use
- #pragma unused(MyReference)
- #pragma unused(LongParam)
-
- // ARA calls this routine periodically. You can also initiate a call
- // to this routine by calling ARATickleMe. When ARA calls this
- // routine the LongParam value will be 0 (zero). When it is called as
- // a result of a call to ARATickleMe the LongParam will have the value
- // you passed to ARATickleMe.
-
- // You can allocate and release memory in this routine.
-
- return ( kSecurityNoErr );
- }
-
-
-
- pascal void MyCompletionProc( SecurityReference MyReference,
- int ResultCode,
- void * DataPtr,
- int DataSize,
- long CompletionParam )
- //===========================================================================
- // Description: this is an example of your a completion routine you can
- // use for calls to asynch ARA services. You can use one
- // completion proc and distinguish the reason it was called
- // by the value passed in the CompletionParam.
- //
- //
- // Parameters: MyReference your unique reference
- // ResultCode result of the asynch ARA call you made
- // DataPtr pointer to the data passed to the ARA
- // proc
- // DataSize actual size of the data
- // CompletionParam additional information you provided
- // to the ARA service proc
- //
- // Return Value: none
- //
- // Creation Date:
- //
- // Modifications:
- //
- //===========================================================================
- {
- // you can remove the unused pragma for any of the parameters you use
- #pragma unused(MyReference)
- #pragma unused(ResultCode)
- #pragma unused(DataPtr)
- #pragma unused(DataSize)
- #pragma unused(CompletionParam)
-
- // WARNING:
- // Do not attempt to allocate or release any memory in this
- // routine. Also don't call any Mac Toolbaox/OS routines
- // that allocate or release memory. If you need to do this,
- // you should call ARATickleMe with a state indicator, and
- // allow your DoMyTickle routine to handle it.
-
- return;
- }